#include "widget.h"
#include "ui_widget.h"
#include <QIcon>
#include <QDebug>

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    this->setWindowTitle("widget标题");

//    // 程序图标
////    QIcon icon("D:/programming/record to git/Qt record to git/Qtest3/Qtest3.webp");
//    QIcon icon(":/Qtest3.webp");
//    this->setWindowIcon(icon);

    // 访问图片文件
    QPixmap pixmap(":/Qtest3.webp");
    // 更改箭头大小
    pixmap = pixmap.scaled(100,100);
    // 后面两个参数作为鼠标真正点击的位置
    QCursor cursor(pixmap,10,10);
    this->setCursor(cursor);

}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_pushButton_add_clicked()
{
    // 窗口透明度
    float opacity = this->windowOpacity();
    if(opacity >= 1.0)
    {
        return;
    }
    qDebug() << opacity;
    opacity += 0.1;
    this->setWindowOpacity(opacity);
}

void Widget::on_pushButton_sub_clicked()
{
    float opacity = this->windowOpacity();
    if(opacity <= 0.0)
    {
        return;
    }
    qDebug() << opacity;
    opacity -= 0.1;
    this->setWindowOpacity(opacity);
}
